package biopepa;

import java.util.ArrayList;


public class DiscreteTrans {
	public String discreteName;
	public String discreteNameWith;
	public String guard;
	public String reset;
	public String rate;
	public NewLocation location;
	public int counter1;
	public int counter2;
	public boolean isContinuous;
	public boolean isReagOrProd;
	
	public DiscreteTrans(NewSpecies species , ActionEnabled action , BiopepaModel model){
		isContinuous = false;
		//Set name
		
		discreteName = action.actionEnabledName;
		discreteNameWith = action.actionEnabledName + "(" + species.speciesName + action.operator + action.stoichiometry + ")";
		//Set guard
		if(action.operator == 1 || action.operator == 3 || action.operator == 6|| action.operator == 7){
			guard = species.speciesName + ">=" + action.stoichiometry ;
		}
		else if(action.operator == 2){
			guard = species.speciesName + "<=" + species.speciesUpper ;
			
		}
		else if(action.operator == 4){
			guard = species.speciesName + "<=" + action.stoichiometry ;
		}
		else if(action.operator == 5){}

		
		//Set reset
		if(action.operator == 1){
			reset = species.speciesName + "-=" + action.stoichiometry;
		}
		else if(action.operator == 2){
			reset = species.speciesName + "+=" + action.stoichiometry;
		}
		else{
		}
		//Set rate
		NewLaw law;
		law = model.lawObjects.get(action.actionEnabledName);
		counter1 = 0;
		counter2 = 0;
	}
	
	public DiscreteTrans(Automaton auto, NewLocation newLocation, NewSpecies species , ActionEnabled action , BiopepaModel model){
		isContinuous = species.isContinuous;
		location = newLocation;
		//Set name		
//		discreteName = action.actionEnabledName + "." + location.locationName;
//		discreteNameWith = action.actionEnabledName + "(" + auto.getAutoName() + action.operator + action.stoichiometry + ")";
		discreteName = action.actionEnabledName;
		discreteNameWith = action.actionEnabledName + "." + location.locationName;
		
		//Set is reagent or product
		if(action.operator == 1 || action.operator == 2 ){
			isReagOrProd = true;
		}
		//Set guard
		if(action.operator == 1 || action.operator == 3 ||  action.operator == 6 || action.operator == 7){
			guard = auto.getAutoName() + ">=" + action.stoichiometry * location.locationStepSize;
		}
		else if(action.operator == 4){
			guard = auto.getAutoName() + "<=" + action.stoichiometry * location.locationStepSize;
		}
		else if(action.operator == 5){}
		else if(action.operator == 2){
			guard = auto.getAutoName() + "<=" + species.speciesUpper * location.locationStepSize;
		}
		
		//Set reset
		if(action.operator == 1){
			reset = auto.getAutoName() + "-=" + action.stoichiometry * location.locationStepSize;
		}
		else if(action.operator == 2 ){
			reset = auto.getAutoName() + "+=" + action.stoichiometry * location.locationStepSize;
		}
		else{
		}
		
		//Set rate
		NewLaw law;
		law = model.lawObjects.get(action.actionEnabledName);
		counter1 = 0;
		counter2 = 0;
	}
	
	public DiscreteTrans(String name, NewLaw law){
		discreteName = name ;
		rate = law.lawExpression;
		isContinuous = false;
	}
	
	public DiscreteTrans(NewLaw law){
		discreteName = law.lawOf;
		rate = law.lawExpression;
		isContinuous = false;
	}

}
